﻿
using System;

using Bootstrap5.Abstractions;

using Microsoft.AspNetCore.Components;

namespace Bootstrap5;

/// <summary>
/// Represent a HTML element by specific tag name.
/// </summary>
public class Element : BootstrapChildContentComponentBase
{
    [Parameter] public string TagName { get; set; } = "div";

    protected override string GetHtmlTagName() => TagName;
}

/// <summary>
/// Represents an unordered list of items, typically rendered as a bulleted list.
/// </summary>
[HtmlTag("ul")]
public class UnorderedList : BootstrapChildContentWithCascadingValueComponentBase<UnorderedList>
{

}
/// <summary>
/// Represents an ordered list of items — typically rendered as a numbered list.
/// </summary>
[CssClass("ol")]
public class OrderedList : BootstrapChildContentWithCascadingValueComponentBase<OrderedList>
{

}
/// <summary>
/// Represent an item in a list. It must be contained in a parent element: an ordered list (<see cref="OrderedList"/>) or an unordered list（<see cref="UnorderedList"/>）.
/// </summary>
[CssClass("li")]
public class ListItem : BootstrapChildContentComponentBase
{
    [CascadingParameter]protected OrderedList OrderedList {  get; set; }
    [CascadingParameter]protected UnorderedList UnorderedList { get; set;  }

    protected override void OnInitialized()
    {
        if(OrderedList is null && UnorderedList is null)
        {
            throw new InvalidOperationException($"The {nameof(ListItem)} component must be contained in a parent element whith is {nameof(UnorderedList)} component or {nameof(OrderedList)} component.");
        }
    }
}

[HtmlTag("ul")]
[CssClass("list-inline")]
public class ListInline : BootstrapChildContentWithCascadingValueComponentBase<ListInline>
{
}

[HtmlTag("li")]
[CssClass("list-inline-item")]
public class ListInlineItem : BootstrapChildContentWithChildCascadingComponentBase<ListInlineItem, ListInline>
{

}

/// <summary>
/// Represents a &lt;span> element.
/// </summary>
[HtmlTag("span")]
public class Span : BootstrapChildContentComponentBase
{

}

/// <summary>
/// Represents a &lt;blockquote> element.
/// </summary>
[HtmlTag("blockquote")]
[CssClass("blockquote")]
public class Blockquote : BootstrapChildContentComponentBase
{
}

#region Figure
/// <summary>
///  Represents self-contained content, potentially with an optional caption.
/// </summary>
[HtmlTag("figure")]
[CssClass("figure")]
public class Figure : BootstrapChildContentWithCascadingValueComponentBase<Figure>
{
}

/// <summary>
/// Represents a caption or legend describing the rest of the contents of its parent <see cref="Figure"/> element.
/// </summary>
[HtmlTag("figcaption")]
[CssClass("figure-caption")]
public class FigureCaption : BootstrapChildContentWithChildCascadingComponentBase<FigureCaption, Figure>
{
}

/// <summary>
/// Represents a <see cref="Image"/> component in its parent <see cref="Figure"/> element.
/// </summary>
[CssClass("figure-img")]
public class FigureImage : Image
{
}
#endregion